﻿using System;
using System.Collections.Generic;
using System.Text;
using HCommon;
using System.Data.SqlClient;
namespace eStock
{

    class tblMinor
    {
        public static int Insert(string MinorCd, string MinorName, string MajorCd)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblMinor(MinorCd,MinorName,MajorCd,CreateBy,CreateDate) values(N'" + Common.xoaNhay(MinorCd) + "',N'" + Common.xoaNhay(MinorName) + "',N'" + Common.xoaNhay(MajorCd) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMinor_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string MinorCd, string MinorName, string MajorCd, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblMinor(MinorCd,MinorName,MajorCd,CreateBy,CreateDate) values(N'" + Common.xoaNhay(MinorCd) + "',N'" + Common.xoaNhay(MinorName) + "',N'" + Common.xoaNhay(MajorCd) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMinor_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string MinorCd, string MinorName, string MajorCd)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblMinor SET MinorName = N'" + Common.xoaNhay(MinorName) + "',MajorCd = N'" + Common.xoaNhay(MajorCd) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE MinorCd = N'" + Common.xoaNhay(MinorCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMinor_Update", ex);
                throw ex;
            }
        }
        public static int Update(string MinorCd, string MinorName, string MajorCd, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblMinor SET MinorName = N'" + Common.xoaNhay(MinorName) + "',MajorCd = N'" + Common.xoaNhay(MajorCd) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE MinorCd = N'" + Common.xoaNhay(MinorCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMinor_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string MinorCd)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblMinor WHERE MinorCd = N'" + Common.xoaNhay(MinorCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMinor_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string MinorCd, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblMinor WHERE MinorCd = N'" + Common.xoaNhay(MinorCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMinor_Delete", ex);
                throw ex;
            }
        }
    }

    class tblCustomer
    {
        public static int Insert(string CustomerCd, string CustomerName, string Addr, string PhoneNo, string FaxNo, string Receiver, string Position, string HomePhone, string Email)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblCustomer(CustomerCd,CustomerName,Addr,PhoneNo,FaxNo,Receiver,Position,HomePhone,Email,CreateBy,CreateDate) values(N'" + Common.xoaNhay(CustomerCd) + "',N'" + Common.xoaNhay(CustomerName) + "',N'" + Common.xoaNhay(Addr) + "',N'" + Common.xoaNhay(PhoneNo) + "',N'" + Common.xoaNhay(FaxNo) + "',N'" + Common.xoaNhay(Receiver) + "',N'" + Common.xoaNhay(Position) + "',N'" + Common.xoaNhay(HomePhone) + "',N'" + Common.xoaNhay(Email) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblCustomer_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string CustomerCd, string CustomerName, string Addr, string PhoneNo, string FaxNo, string Receiver, string Position, string HomePhone, string Email, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblCustomer(CustomerCd,CustomerName,Addr,PhoneNo,FaxNo,Receiver,Position,HomePhone,Email,CreateBy,CreateDate) values(N'" + Common.xoaNhay(CustomerCd) + "',N'" + Common.xoaNhay(CustomerName) + "',N'" + Common.xoaNhay(Addr) + "',N'" + Common.xoaNhay(PhoneNo) + "',N'" + Common.xoaNhay(FaxNo) + "',N'" + Common.xoaNhay(Receiver) + "',N'" + Common.xoaNhay(Position) + "',N'" + Common.xoaNhay(HomePhone) + "',N'" + Common.xoaNhay(Email) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblCustomer_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string CustomerCd, string CustomerName, string Addr, string PhoneNo, string FaxNo, string Receiver, string Position, string HomePhone, string Email)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblCustomer SET CustomerName = N'" + Common.xoaNhay(CustomerName) + "',Addr = N'" + Common.xoaNhay(Addr) + "',PhoneNo = N'" + Common.xoaNhay(PhoneNo) + "',FaxNo = N'" + Common.xoaNhay(FaxNo) + "',Receiver = N'" + Common.xoaNhay(Receiver) + "',Position = N'" + Common.xoaNhay(Position) + "',HomePhone = N'" + Common.xoaNhay(HomePhone) + "',Email = N'" + Common.xoaNhay(Email) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE CustomerCd = N'" + Common.xoaNhay(CustomerCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblCustomer_Update", ex);
                throw ex;
            }
        }
        public static int Update(string CustomerCd, string CustomerName, string Addr, string PhoneNo, string FaxNo, string Receiver, string Position, string HomePhone, string Email, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblCustomer SET CustomerName = N'" + Common.xoaNhay(CustomerName) + "',Addr = N'" + Common.xoaNhay(Addr) + "',PhoneNo = N'" + Common.xoaNhay(PhoneNo) + "',FaxNo = N'" + Common.xoaNhay(FaxNo) + "',Receiver = N'" + Common.xoaNhay(Receiver) + "',Position = N'" + Common.xoaNhay(Position) + "',HomePhone = N'" + Common.xoaNhay(HomePhone) + "',Email = N'" + Common.xoaNhay(Email) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE CustomerCd = N'" + Common.xoaNhay(CustomerCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblCustomer_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string CustomerCd)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblCustomer WHERE CustomerCd = N'" + Common.xoaNhay(CustomerCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblCustomer_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string CustomerCd, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblCustomer WHERE CustomerCd = N'" + Common.xoaNhay(CustomerCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblCustomer_Delete", ex);
                throw ex;
            }
        }
    }

    class tblMajor
    {
        public static int Insert(string MajorCd, string MajorName, string TableMap, string ValueMember, string DisplayMember)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblMajor(MajorCd,MajorName,TableMap,ValueMember,DisplayMember) values(N'" + Common.xoaNhay(MajorCd) + "',N'" + Common.xoaNhay(MajorName) + "',N'" + Common.xoaNhay(TableMap) + "',N'" + Common.xoaNhay(ValueMember) + "',N'" + Common.xoaNhay(DisplayMember) + "')");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMajor_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string MajorCd, string MajorName, string TableMap, string ValueMember, string DisplayMember, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblMajor(MajorCd,MajorName,TableMap,ValueMember,DisplayMember) values(N'" + Common.xoaNhay(MajorCd) + "',N'" + Common.xoaNhay(MajorName) + "',N'" + Common.xoaNhay(TableMap) + "',N'" + Common.xoaNhay(ValueMember) + "',N'" + Common.xoaNhay(DisplayMember) + "')", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMajor_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string MajorCd, string MajorName, string TableMap, string ValueMember, string DisplayMember)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblMajor SET MajorName = N'" + Common.xoaNhay(MajorName) + "',TableMap = N'" + Common.xoaNhay(TableMap) + "',ValueMember = N'" + Common.xoaNhay(ValueMember) + "',DisplayMember = N'" + Common.xoaNhay(DisplayMember) + "' WHERE MajorCd = N'" + Common.xoaNhay(MajorCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMajor_Update", ex);
                throw ex;
            }
        }
        public static int Update(string MajorCd, string MajorName, string TableMap, string ValueMember, string DisplayMember, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblMajor SET MajorName = N'" + Common.xoaNhay(MajorName) + "',TableMap = N'" + Common.xoaNhay(TableMap) + "',ValueMember = N'" + Common.xoaNhay(ValueMember) + "',DisplayMember = N'" + Common.xoaNhay(DisplayMember) + "' WHERE MajorCd = N'" + Common.xoaNhay(MajorCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMajor_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string MajorCd)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblMajor WHERE MajorCd = N'" + Common.xoaNhay(MajorCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMajor_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string MajorCd, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblMajor WHERE MajorCd = N'" + Common.xoaNhay(MajorCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblMajor_Delete", ex);
                throw ex;
            }
        }
    }

    class tblUSER
    {
        public static int Insert(string user_fullname, string user_name, string user_pwd, string group_cd, string dept_cd, string user_code)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblUSER(user_fullname,user_name,user_pwd,group_cd,dept_cd,user_code,CreateBy,CreateDate) values(N'" + Common.xoaNhay(user_fullname) + "',N'" + Common.xoaNhay(user_name) + "',N'" + Common.xoaNhay(user_pwd) + "',N'" + Common.xoaNhay(group_cd) + "',N'" + Common.xoaNhay(dept_cd) + "',N'" + Common.xoaNhay(user_code) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblUSER_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string user_fullname, string user_name, string user_pwd, string group_cd, string dept_cd, string user_code, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblUSER(user_fullname,user_name,user_pwd,group_cd,dept_cd,user_code,CreateBy,CreateDate) values(N'" + Common.xoaNhay(user_fullname) + "',N'" + Common.xoaNhay(user_name) + "',N'" + Common.xoaNhay(user_pwd) + "',N'" + Common.xoaNhay(group_cd) + "',N'" + Common.xoaNhay(dept_cd) + "',N'" + Common.xoaNhay(user_code) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblUSER_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string user_fullname, string user_name, string user_pwd, string group_cd, string dept_cd, string user_code)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblUSER SET user_fullname = N'" + Common.xoaNhay(user_fullname) + "',user_pwd = N'" + Common.xoaNhay(user_pwd) + "',group_cd = N'" + Common.xoaNhay(group_cd) + "',dept_cd = N'" + Common.xoaNhay(dept_cd) + "',user_code = N'" + Common.xoaNhay(user_code) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE user_name = N'" + Common.xoaNhay(user_name) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblUSER_Update", ex);
                throw ex;
            }
        }
        public static int Update(string user_fullname, string user_name, string user_pwd, string group_cd, string dept_cd, string user_code, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblUSER SET user_fullname = N'" + Common.xoaNhay(user_fullname) + "',user_pwd = N'" + Common.xoaNhay(user_pwd) + "',group_cd = N'" + Common.xoaNhay(group_cd) + "',dept_cd = N'" + Common.xoaNhay(dept_cd) + "',user_code = N'" + Common.xoaNhay(user_code) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE user_name = N'" + Common.xoaNhay(user_name) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblUSER_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string user_name)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblUSER WHERE user_name = N'" + Common.xoaNhay(user_name) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblUSER_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string user_name, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblUSER WHERE user_name = N'" + Common.xoaNhay(user_name) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblUSER_Delete", ex);
                throw ex;
            }
        }
    }

    class tblItem
    {
        public static int Insert(string ItemCd, string ItemName, string UnitCd, string Origin)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblItem(ItemCd,ItemName,UnitCd,Origin,CreateBy,CreateDate) values(N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(ItemName) + "',N'" + Common.xoaNhay(UnitCd) + "',N'" + Common.xoaNhay(Origin) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string ItemCd, string ItemName, string UnitCd, string Origin, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblItem(ItemCd,ItemName,UnitCd,Origin,CreateBy,CreateDate) values(N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(ItemName) + "',N'" + Common.xoaNhay(UnitCd) + "',N'" + Common.xoaNhay(Origin) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string ItemCd, string ItemName, string UnitCd, string Origin)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblItem SET ItemName = N'" + Common.xoaNhay(ItemName) + "',UnitCd = N'" + Common.xoaNhay(UnitCd) + "',Origin = N'" + Common.xoaNhay(Origin) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ItemCd = N'" + Common.xoaNhay(ItemCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Update", ex);
                throw ex;
            }
        }
        public static int Update(string ItemCd, string ItemName, string UnitCd, string Origin, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblItem SET ItemName = N'" + Common.xoaNhay(ItemName) + "',UnitCd = N'" + Common.xoaNhay(UnitCd) + "',Origin = N'" + Common.xoaNhay(Origin) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ItemCd = N'" + Common.xoaNhay(ItemCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string ItemCd)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblItem WHERE ItemCd = N'" + Common.xoaNhay(ItemCd) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string ItemCd, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblItem WHERE ItemCd = N'" + Common.xoaNhay(ItemCd) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Delete", ex);
                throw ex;
            }
        }
    }

    class tblItem_Price
    {
        public static int Insert(string ItemCd, string FromDate, string Price)
        {
            try
            {
                return Dao.ExecSca_SQL("INSERT INTO tblItem_Price(ItemCd,FromDate,Price,CreateBy,CreateDate) output Inserted.ID values(N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(FromDate) + "',N'" + Common.xoaNhay(Price) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Price_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string ItemCd, string FromDate, string Price, SqlTransaction objTrans)
        {
            try
            {
                return Dao.ExecSca_SQL("INSERT INTO tblItem_Price(ItemCd,FromDate,Price,CreateBy,CreateDate) output Inserted.ID values(N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(FromDate) + "',N'" + Common.xoaNhay(Price) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Price_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string ID, string ItemCd, string FromDate, string Price)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblItem_Price SET ItemCd = N'" + Common.xoaNhay(ItemCd) + "',FromDate = N'" + Common.xoaNhay(FromDate) + "',Price = N'" + Common.xoaNhay(Price) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ID = N'" + Common.xoaNhay(ID) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Price_Update", ex);
                throw ex;
            }
        }
        public static int Update(string ID, string ItemCd, string FromDate, string Price, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblItem_Price SET ItemCd = N'" + Common.xoaNhay(ItemCd) + "',FromDate = N'" + Common.xoaNhay(FromDate) + "',Price = N'" + Common.xoaNhay(Price) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ID = N'" + Common.xoaNhay(ID) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Price_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string ID)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblItem_Price WHERE ID = N'" + Common.xoaNhay(ID) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Price_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string ID, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblItem_Price WHERE ID = N'" + Common.xoaNhay(ID) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblItem_Price_Delete", ex);
                throw ex;
            }
        }
    }

    class tblQuote
    {
        public static int Insert(string QuoteNo, string CustomerCd, string Content, string TotalAmt, string Status, string PhoneNo, string FaxNo, string Addr, string Receiver, string Position, string HomePhone, string Email)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblQuote(QuoteNo,CustomerCd,Content,TotalAmt,Status,PhoneNo,FaxNo,Addr,Receiver,Position,HomePhone,Email,CreateBy,CreateDate) values(N'" + Common.xoaNhay(QuoteNo) + "',N'" + Common.xoaNhay(CustomerCd) + "',N'" + Common.xoaNhay(Content) + "',N'" + Common.xoaNhay(TotalAmt) + "',N'" + Common.xoaNhay(Status) + "',N'" + Common.xoaNhay(PhoneNo) + "',N'" + Common.xoaNhay(FaxNo) + "',N'" + Common.xoaNhay(Addr) + "',N'" + Common.xoaNhay(Receiver) + "',N'" + Common.xoaNhay(Position) + "',N'" + Common.xoaNhay(HomePhone) + "',N'" + Common.xoaNhay(Email) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string QuoteNo, string CustomerCd, string Content, string TotalAmt, string Status, string PhoneNo, string FaxNo, string Addr, string Receiver, string Position, string HomePhone, string Email, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblQuote(QuoteNo,CustomerCd,Content,TotalAmt,Status,PhoneNo,FaxNo,Addr,Receiver,Position,HomePhone,Email,CreateBy,CreateDate) values(N'" + Common.xoaNhay(QuoteNo) + "',N'" + Common.xoaNhay(CustomerCd) + "',N'" + Common.xoaNhay(Content) + "',N'" + Common.xoaNhay(TotalAmt) + "',N'" + Common.xoaNhay(Status) + "',N'" + Common.xoaNhay(PhoneNo) + "',N'" + Common.xoaNhay(FaxNo) + "',N'" + Common.xoaNhay(Addr) + "',N'" + Common.xoaNhay(Receiver) + "',N'" + Common.xoaNhay(Position) + "',N'" + Common.xoaNhay(HomePhone) + "',N'" + Common.xoaNhay(Email) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string QuoteNo, string CustomerCd, string Content, string TotalAmt, string Status, string PhoneNo, string FaxNo, string Addr, string Receiver, string Position, string HomePhone, string Email)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblQuote SET CustomerCd = N'" + Common.xoaNhay(CustomerCd) + "',Content = N'" + Common.xoaNhay(Content) + "',TotalAmt = N'" + Common.xoaNhay(TotalAmt) + "',Status = N'" + Common.xoaNhay(Status) + "',PhoneNo = N'" + Common.xoaNhay(PhoneNo) + "',FaxNo = N'" + Common.xoaNhay(FaxNo) + "',Addr = N'" + Common.xoaNhay(Addr) + "',Receiver = N'" + Common.xoaNhay(Receiver) + "',Position = N'" + Common.xoaNhay(Position) + "',HomePhone = N'" + Common.xoaNhay(HomePhone) + "',Email = N'" + Common.xoaNhay(Email) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Update", ex);
                throw ex;
            }
        }
        public static int Update(string QuoteNo, string CustomerCd, string Content, string TotalAmt, string Status, string PhoneNo, string FaxNo, string Addr, string Receiver, string Position, string HomePhone, string Email, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblQuote SET CustomerCd = N'" + Common.xoaNhay(CustomerCd) + "',Content = N'" + Common.xoaNhay(Content) + "',TotalAmt = N'" + Common.xoaNhay(TotalAmt) + "',Status = N'" + Common.xoaNhay(Status) + "',PhoneNo = N'" + Common.xoaNhay(PhoneNo) + "',FaxNo = N'" + Common.xoaNhay(FaxNo) + "',Addr = N'" + Common.xoaNhay(Addr) + "',Receiver = N'" + Common.xoaNhay(Receiver) + "',Position = N'" + Common.xoaNhay(Position) + "',HomePhone = N'" + Common.xoaNhay(HomePhone) + "',Email = N'" + Common.xoaNhay(Email) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string QuoteNo)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblQuote WHERE QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string QuoteNo, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblQuote WHERE QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Delete", ex);
                throw ex;
            }
        }
    }

    class tblQuote_No
    {
        public static int Insert(string year, string user_name, string QuoteNo)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblQuote_No(year,user_name,QuoteNo) values(N'" + Common.xoaNhay(year) + "',N'" + Common.xoaNhay(user_name) + "',N'" + Common.xoaNhay(QuoteNo) + "')");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_No_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string year, string user_name, string QuoteNo, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("INSERT INTO tblQuote_No(year,user_name,QuoteNo) values(N'" + Common.xoaNhay(year) + "',N'" + Common.xoaNhay(user_name) + "',N'" + Common.xoaNhay(QuoteNo) + "')", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_No_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string year, string user_name, string QuoteNo)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblQuote_No SET QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "' WHERE user_name = N'" + Common.xoaNhay(user_name) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_No_Update", ex);
                throw ex;
            }
        }
        public static int Update(string year, string user_name, string QuoteNo, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblQuote_No SET QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "' WHERE user_name = N'" + Common.xoaNhay(user_name) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_No_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string user_name)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblQuote_No WHERE user_name = N'" + Common.xoaNhay(user_name) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_No_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string user_name, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblQuote_No WHERE user_name = N'" + Common.xoaNhay(user_name) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_No_Delete", ex);
                throw ex;
            }
        }
    }

    class tblQuote_Item
    {
        public static int Insert(string QuoteNo, string ItemCd, string Quantity, string Price, string Amount)
        {
            try
            {
                return Dao.ExecSca_SQL("INSERT INTO tblQuote_Item(QuoteNo,ItemCd,Quantity,Price,Amount,CreateBy,CreateDate) output Inserted.ID values(N'" + Common.xoaNhay(QuoteNo) + "',N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(Quantity) + "',N'" + Common.xoaNhay(Price) + "',N'" + Common.xoaNhay(Amount) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Item_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string QuoteNo, string ItemCd, string Quantity, string Price, string Amount, SqlTransaction objTrans)
        {
            try
            {
                return Dao.ExecSca_SQL("INSERT INTO tblQuote_Item(QuoteNo,ItemCd,Quantity,Price,Amount,CreateBy,CreateDate) output Inserted.ID values(N'" + Common.xoaNhay(QuoteNo) + "',N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(Quantity) + "',N'" + Common.xoaNhay(Price) + "',N'" + Common.xoaNhay(Amount) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Item_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string QuoteNo, string ID, string ItemCd, string Quantity, string Price, string Amount)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblQuote_Item SET QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "',ItemCd = N'" + Common.xoaNhay(ItemCd) + "',Quantity = N'" + Common.xoaNhay(Quantity) + "',Price = N'" + Common.xoaNhay(Price) + "',Amount = N'" + Common.xoaNhay(Amount) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ID = N'" + Common.xoaNhay(ID) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Item_Update", ex);
                throw ex;
            }
        }
        public static int Update(string QuoteNo, string ID, string ItemCd, string Quantity, string Price, string Amount, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblQuote_Item SET QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "',ItemCd = N'" + Common.xoaNhay(ItemCd) + "',Quantity = N'" + Common.xoaNhay(Quantity) + "',Price = N'" + Common.xoaNhay(Price) + "',Amount = N'" + Common.xoaNhay(Amount) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ID = N'" + Common.xoaNhay(ID) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Item_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string ID)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblQuote_Item WHERE ID = N'" + Common.xoaNhay(ID) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Item_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string ID, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblQuote_Item WHERE ID = N'" + Common.xoaNhay(ID) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblQuote_Item_Delete", ex);
                throw ex;
            }
        }
    }

    class tblImExport
    {
        public static int Insert(string QuoteNo, string ImExportKind, string ItemCd, string Quantity)
        {
            try
            {
                return Dao.ExecSca_SQL("INSERT INTO tblImExport(QuoteNo,ImExportKind,ItemCd,Quantity,CreateBy,CreateDate) output Inserted.ID values(N'" + Common.xoaNhay(QuoteNo) + "',N'" + Common.xoaNhay(ImExportKind) + "',N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(Quantity) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblImExport_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }
        public static int Insert(string QuoteNo, string ImExportKind, string ItemCd, string Quantity, SqlTransaction objTrans)
        {
            try
            {
                return Dao.ExecSca_SQL("INSERT INTO tblImExport(QuoteNo,ImExportKind,ItemCd,Quantity,CreateBy,CreateDate) output Inserted.ID values(N'" + Common.xoaNhay(QuoteNo) + "',N'" + Common.xoaNhay(ImExportKind) + "',N'" + Common.xoaNhay(ItemCd) + "',N'" + Common.xoaNhay(Quantity) + "',N'" + Common.xoaNhay(Settings.myUserName) + "',GetDate())", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblImExport_Insert", ex);
                if (ex.Message.Contains("Violation of PRIMARY KEY"))
                {
                    throw new Exception("Đã tồn tại Mã này, vui lòng kiểm tra lại."); // Nhớ sửa lại Mã đoạn này
                }
                else
                {
                    throw ex;
                }
            }
        }

        public static int Update(string ID, string QuoteNo, string ImExportKind, string ItemCd, string Quantity)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblImExport SET QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "',ImExportKind = N'" + Common.xoaNhay(ImExportKind) + "',ItemCd = N'" + Common.xoaNhay(ItemCd) + "',Quantity = N'" + Common.xoaNhay(Quantity) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ID = N'" + Common.xoaNhay(ID) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblImExport_Update", ex);
                throw ex;
            }
        }
        public static int Update(string ID, string QuoteNo, string ImExportKind, string ItemCd, string Quantity, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("UPDATE tblImExport SET QuoteNo = N'" + Common.xoaNhay(QuoteNo) + "',ImExportKind = N'" + Common.xoaNhay(ImExportKind) + "',ItemCd = N'" + Common.xoaNhay(ItemCd) + "',Quantity = N'" + Common.xoaNhay(Quantity) + "',UpdateBy = N'" + Common.xoaNhay(Settings.myUserName) + "',UpdateDate = GetDate() WHERE ID = N'" + Common.xoaNhay(ID) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblImExport_Update", ex);
                throw ex;
            }
        }

        public static int Delete(string ID)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblImExport WHERE ID = N'" + Common.xoaNhay(ID) + "'");
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblImExport_Delete", ex);
                throw ex;
            }
        }
        public static int Delete(string ID, SqlTransaction objTrans)
        {
            try
            {
                return Dao.Exec_SQL("DELETE tblImExport WHERE ID = N'" + Common.xoaNhay(ID) + "'", objTrans);
            }
            catch (Exception ex)
            {
                Common.GhiLog("tblImExport_Delete", ex);
                throw ex;
            }
        }
    }
}